/*
 * Duplicate Detector Copyright (C) 2010 Marco Biscaro <marcobiscaro2112@gmail.com>
 * 
 * This file is part of Duplicate Detector.
 *
 * Duplicate Detector is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Duplicate Detector is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Duplicate Detector.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.duplicatedetector;

import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.googlecode.duplicatedetector.i18n.Languages;
import com.googlecode.duplicatedetector.i18n.Messages;
import com.googlecode.duplicatedetector.properties.PropertiesManager;
import com.googlecode.duplicatedetector.util.Logger;
import com.googlecode.duplicatedetector.view.LookAndFeels;
import com.googlecode.duplicatedetector.view.MainFrame;

/**
 * The program's main class.
 * 
 * @author Marco Biscaro
 */
public class Main {

	private static final Logger LOGGER = new Logger(Main.class);

	public static void main(String[] args) {
		String language = PropertiesManager.getProperty("language");
		LOGGER.debug("Using language " + language);
		Messages.setLocale(Languages.LANGUAGES.get(language));
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				try {
					LookAndFeel laf = LookAndFeels.LOOK_AND_FEELS
							.get(PropertiesManager.getProperty("laf"));
					LOGGER.debug("Using look and feel " + laf);
					UIManager.setLookAndFeel(laf);
				} catch (UnsupportedLookAndFeelException e) {
					LOGGER.exception("Error setting look and feel", e);
				}
				LOGGER.info("Starting Duplicate Detector");
				new MainFrame().setVisible(true);
			}

		});
	}
}
